package syyrjx.controller;

import syyrjx.jdbc.QuestionDB;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

public class GotoExamServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.gotoExam(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.gotoExam(request, response);
    }
    private void gotoExam(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        QuestionDB qdb = new QuestionDB();
        List<Map<String,Object>> questionList = qdb.getQuestion(3);
        request.getSession(false).setAttribute("questionList",questionList);
        request.setAttribute("questionList",questionList);
        request.getRequestDispatcher("exam.jsp").forward(request,response);
    }
}
